/**
 * StarInfoFrameExplored.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.layout.AnchorLayout;
import com.ardor3d.extension.ui.layout.AnchorLayoutData;
import com.ardor3d.extension.ui.util.Alignment;
import com.roslan.games.moo3d.data.Star;
import com.roslan.games.moo3d.data.Star.Environment;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * This Panel displays the information about the currently selected Star which has been explored before.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 10, 2011
 */
public class StarInfoFrameExplored extends StarInfoFrameExploredBase {

	/**
	 * The label for the star's description.
	 */
	protected final UILabel descriptionValueLabel;

	/**
	 * The label for the star's range.
	 */
	protected final UILabel rangeValueLabel;

	/**
	 * Default no-arg constructor.
	 */
	public StarInfoFrameExplored() {
		super("StarInfoFrameExplored");

		final UIPanel panel = new UIPanel();
		panel.setLayout(new AnchorLayout());
		panel.setMargin(HudManager.MARGINS_ZERO);
		panel.setPadding(HudManager.PADDING_2000);
		panel.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel);

		descriptionValueLabel = new UILabel("");
		descriptionValueLabel.setStyledText(true);
		descriptionValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -6));
		panel.add(descriptionValueLabel);

		rangeValueLabel = new UILabel("");
		rangeValueLabel.setStyledText(true);
		rangeValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -42));
		panel.add(rangeValueLabel);
	}

	/**
	 * Update the information to the currently selected Star (or Colony).
	 * 
	 * @param starNode - the Star (or Colony) whose info is to be updated
	 */
	@Override
	public void update(StarNode starNode) {
		super.update(starNode);

		Star star = starNode.getStar();
//		descriptionValueLabel.setText("[b]" + ((star.environment == Environment.NONE) ? "<<NO HABITABLE PLANETS>>" : "<<NO COLONIES>>") + "[/b]");
//		rangeValueLabel.setText("[b]Range " + starNode.range + " parsecs[/b]");
		descriptionValueLabel.setText(((star.environment == Environment.NONE) ? "<<NO HABITABLE PLANETS>>" : "<<NO COLONIES>>"));
		rangeValueLabel.setText("Range: " + starNode.range + " parsecs");

		updateAndpack();
	}

}
